import { checkScope } from '$lib/auth'; import { redirect } from '@sveltejs/kit'; export const load = async (e) => { const scopes = e.params.scopes .split(' ') .flatMap((v) => v.split(',')) .flatMap((v) => v.split('+')) .filter((v) => v); const session = await e.locals.auth(); const hasScopes: string[] = session.tokens.scope?.split(' ') ?? []; if (checkScope(session, scopes, false)) throw redirect(303, '../..'); else return { missingScopes: scopes.filter((scope) => !hasScopes.includes(scope)), }; };